package com.eureka.pay.event;

import com.alibaba.fastjson.JSONObject;
import com.eureka.bclass.util.LoggerUtil;
import com.eureka.pay.configurer.properties.AdvancePaymentProperties;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Description: 监听 - 异步添加预支付记录（生成未支付的订单）
 * @Author: lixing
 * @Date: 2020/4/26 21:20
 */
@Component
@Async("asyncTaskExecutor")
public class PayEventListener {
    /**
     * @Description 异步添加预支付记录（生成未支付的订单，需要做幂等）
     * @Author lixing
     * @Date 2020/4/26 21:38
     * @Param [event]
     */
    @EventListener
    public void payRecord(PayEvent event) {
        AdvancePaymentProperties advancePaymentProperties = event.getAdvancePaymentProperties();
        LoggerUtil.info("");
        LoggerUtil.info("异步添加预支付记录-----start");
        LoggerUtil.info(JSONObject.toJSONString(advancePaymentProperties));
        LoggerUtil.info("异步添加预支付记录-----end");
//        if (!hkSeckillService.save(hkSeckillEntity)) {
//            LoggerUtil.error(MessageFormat.format("号卡秒杀记录入库失败：{10}", JSONObject.toJSONString(hkSeckillEntity)));
//        }
    }
}
